#coding=utf-8
'''
# @Name:__init__.py
# @author:mysouil
# @Description:用户模块的蓝图
# @DATE:2022/9/21 8:00
# @Modified By:
'''

from flask import Blueprint
from flask_restful import Api
from comment.utils.output import output_json
from comment.utils.request_hook import jwt_request_auth
from shopping.resources.user.user_resource import Shopping_User, User_MSM, AuthorizationCodeResource,RegisterUserResource,\
    LoginUserResource,IsExistPhoneResource,UserLoginOutResource

# 创建蓝图
user_bp = Blueprint('users',__name__,url_prefix='/user')

user_api = Api(user_bp)  # 创建蓝图中的资源api

#  在当前用户模块添加请求钩子
# user_bp.before_request(jwt_request_auth)

# 使用自定义的json格式，替代装饰器的写法
user_api.representation('application/json')(output_json)

# 加载当前模块的资源
user_api.add_resource(Shopping_User,'/hello')
user_api.add_resource(User_MSM,'/sms')
user_api.add_resource(AuthorizationCodeResource,'/authorization')
user_api.add_resource(RegisterUserResource,'/register',endpoint='register')
user_api.add_resource(LoginUserResource,'/login')
user_api.add_resource(IsExistPhoneResource,'/isExist')
user_api.add_resource(UserLoginOutResource,'/loginOut')